/**
 * 
 */
package cn.softTank.BpelModelImpl;

import org.dom4j.DocumentHelper;
import org.dom4j.Element;

import cn.softTank.BpelModel.ExtensibleElement;

/**
 * @author Yuzone (smartzxy@gmail.com)
 * 
 */
public class ExtensibleElementImpl implements ExtensibleElement {

	private String documentation;
	protected Element node;

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.ExtensibleElement#getDocumentation()
	 */
	@Override
	public String getDocumentation() {
		return this.documentation;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * cn.softTank.BpelModel.ExtensibleElement#setDocumentation(java.lang.String
	 * )
	 */
	@Override
	public void setDocumentation(String documentation) {
		this.documentation = documentation;
	}

	@Override
	public Element toElement() {
		// Create element with default name: BPELNode.
		node = DocumentHelper.createElement("BPELNode");
		// Add documentation element if it is set.
		if (documentation != null) {
			Element doc = DocumentHelper.createElement("documentation");
			doc.addText(documentation);
			node.add(doc);
		}
		return node;
	}

	@Override
	public String toXml() {
		String xml = "";
		if (documentation != null) {
			xml = "<documentation>"+documentation+"</documentation>";
		}
		return xml;
	}
}
